import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
var _excluded = ["lovId"];

/**
 * DimensionConfig - 数据维度配置 service
 * @date:  2019-7-16
 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameters, isTenantRoleLevel } from 'utils/utils';

function urlPrefix(params) {
  return "".concat(CPAAS_PLATFORM, "/v1").concat(isTenantRoleLevel() ? "/".concat(params.tenantId, "/") : '/');
}
/**
 * 条件查询值集头
 * @param {Object} params - 查询参数
 */


export function queryLovHeadersList(_x) {
  return _queryLovHeadersList.apply(this, arguments);
}
/**
 * 批量更新值集头
 * @param {Array} params - 更新值集头
 */

function _queryLovHeadersList() {
  _queryLovHeadersList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            query = parseParameters(params);
            return _context.abrupt("return", request("".concat(urlPrefix(params), "lov-headers"), {
              method: 'GET',
              query: query
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryLovHeadersList.apply(this, arguments);
}

export function updateLovHeaders(_x2) {
  return _updateLovHeaders.apply(this, arguments);
}
/**
 * 批量插入值集头
 * @param {Array} params - 插入值集头
 */

function _updateLovHeaders() {
  _updateLovHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(urlPrefix(params), "lov-headers"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _updateLovHeaders.apply(this, arguments);
}

export function insertLovHeaders(_x3) {
  return _insertLovHeaders.apply(this, arguments);
}
/**
 * 批量删除值集头
 * @param {Array} params - 删除值集头
 */

function _insertLovHeaders() {
  _insertLovHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(urlPrefix(params), "lov-headers"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _insertLovHeaders.apply(this, arguments);
}

export function deleteLovHeaders(_x4) {
  return _deleteLovHeaders.apply(this, arguments);
}
/**
 * 批量更新值集值
 * @param {Array} params - 更新值集值
 */

function _deleteLovHeaders() {
  _deleteLovHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(params) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(urlPrefix(params), "lov-headers"), {
              method: 'DELETE',
              body: params
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _deleteLovHeaders.apply(this, arguments);
}

export function updateLovValues(_x5) {
  return _updateLovValues.apply(this, arguments);
}
/**
 * 批量插入值集值
 * @param {Array} params - 插入值集值
 */

function _updateLovValues() {
  _updateLovValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(params) {
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            return _context5.abrupt("return", request("".concat(urlPrefix(params), "lov-values"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _updateLovValues.apply(this, arguments);
}

export function insertLovValues(_x6) {
  return _insertLovValues.apply(this, arguments);
}
/**
 * 批量删除值集值
 * @param {Array} params - 删除值集值
 */

function _insertLovValues() {
  _insertLovValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            return _context6.abrupt("return", request("".concat(urlPrefix(params), "lov-values"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _insertLovValues.apply(this, arguments);
}

export function deleteLovValues(_x7) {
  return _deleteLovValues.apply(this, arguments);
}
/**
 * 根据值集头 ID 查询值集值
 * @param {Object} params - 查询参数
 */

function _deleteLovValues() {
  _deleteLovValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(params) {
    var deleteRows;
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            deleteRows = params.deleteRows;
            return _context7.abrupt("return", request("".concat(urlPrefix(params), "lov-values"), {
              method: 'DELETE',
              body: deleteRows
            }));

          case 2:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _deleteLovValues.apply(this, arguments);
}

export function queryLovValues(_x8) {
  return _queryLovValues.apply(this, arguments);
}
/**
 * 查询单个值集头
 * @param {Number} params - Lov Id
 */

function _queryLovValues() {
  _queryLovValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
    var lovId, queryProp;
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            lovId = params.lovId, queryProp = _objectWithoutProperties(params, _excluded);
            return _context8.abrupt("return", request("".concat(urlPrefix(params), "lov-headers/").concat(lovId, "/values"), {
              method: 'GET',
              query: queryProp
            }));

          case 2:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _queryLovValues.apply(this, arguments);
}

export function queryLovHeader(_x9) {
  return _queryLovHeader.apply(this, arguments);
}
/**
 * 根据值集头 ID 查询值集值
 * @param {Object} params - 查询参数
 */

function _queryLovHeader() {
  _queryLovHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params) {
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            return _context9.abrupt("return", request("".concat(urlPrefix(params), "lov-headers/").concat(params.lovId)));

          case 1:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _queryLovHeader.apply(this, arguments);
}

export function copyLov(_x10) {
  return _copyLov.apply(this, arguments);
}

function _copyLov() {
  _copyLov = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(params) {
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            return _context10.abrupt("return", request("".concat(urlPrefix(params), "lov/copy"), {
              method: 'POST',
              body: params,
              query: params
            }));

          case 1:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _copyLov.apply(this, arguments);
}